package com.shg.service.impl;

import org.springframework.stereotype.Service;

import com.shg.bean.OrderItem;
import com.shg.bean.SoldBook;
import com.shg.bean.Users;
import com.shg.service.OrderItemService;

@Service
public class OrderItemServiceBean extends BasiceDaoImpl<OrderItem> implements
		OrderItemService {
	/**
	 * 订单查询
	 */
	public OrderItem getItem(String orderid){
		OrderItem orderItem = (OrderItem) sessionFactory.getCurrentSession().get(OrderItem.class, orderid);
		Users users = (Users) sessionFactory.getCurrentSession().get(Users.class, orderItem.getUsers().getId());
		orderItem.setUsers(users);
		for(SoldBook book:orderItem.getSoldBooks()){
			orderItem.setAmount(orderItem.getAmount()+book.getPrice());
		}
		return orderItem;
	}
}
